package homework.ooday04.animal;

public class Test {
    public static void main(String[] args) {
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("小黑",1,"黑");
        animals[1] = new Dog("小灰",2,"灰");
        animals[2] = new Chick("小花",1,"黄");
        animals[3] = new Fish("小金",1,"金");
        animals[4] = new Fish("小银",1,"银");

        for(int i=0;i<animals.length;i++){
            Animal a = animals[i];
            System.out.println(a.name);
            System.out.println(a.age);
            System.out.println(a.color);
            a.eat();
            a.drink();
            if(a instanceof Dog){
                Dog d = (Dog)a;
                d.lookHome();
            }
            if(a instanceof Chick){
                Chick c = (Chick)a;
                c.layEggs();
            }
            if(a instanceof Swim){
                Swim s = (Swim)a;
                s.swim();
            }
        }

        Master master = new Master();
        master.feed(animals[0]);
        master.feed(animals[2]);
        master.feed(animals[4]);
    }
}
